package department

import (
	"encoding/json"
	"net/url"

	"gitee.com/suguo79/xyh"
)

// 1.获取学校内部组织结构
func DeptList(orgid, deptid *string) {

}

// 2.获取家校部门列表
func SchoolDeptlist(orgid, deptid *string) {

}

// 3.获取内部部门信息
func DeptInfo(orgid, deptid *string) (*RespDepartment, error) {
	if orgid == nil || deptid == nil {
		return nil, nil
	}

	params := url.Values{}
	params.Add("org_id", *orgid)
	params.Add("dept_id", *deptid)

	payload, err := xyh.HttpRequest("cgi-bin/dept/info", params, nil)
	if err != nil {
		return nil, err
	}

	data := &RespDepartment{}
	if err := json.Unmarshal(*payload, &data); err != nil {
		return nil, err
	}
	return data, nil
}

// 4.获取家校部门信息
func SchoolDeptinfo(orgid, deptid *string) (*RespDepartment, error) {
	if orgid == nil || deptid == nil {
		return nil, nil
	}

	params := url.Values{}
	params.Add("org_id", *orgid)
	params.Add("dept_id", *deptid)

	payload, err := xyh.HttpRequest("cgi-bin/schooldept/info", params, nil)
	if err != nil {
		return nil, err
	}

	data := &RespDepartment{}
	if err := json.Unmarshal(*payload, &data); err != nil {
		return nil, err
	}
	return data, nil
}

// 5.获取学校基本信息
func SchoolOrginfo(orgid, deptid *string) {

}
